package com.woohua.thread.life;

/***
 * @title ChildThread
 * @description
 * @author woo hua
 * @version 1.0.0
 * @create 2023/3/10 13:32
 **/
public class ChildThread implements Runnable {

    Thread parentThread;

    public ChildThread(Thread parentThread) {
        this.parentThread = parentThread;
    }

    @Override
    public void run() {

        try {
            Thread.sleep(2000);
            // 这里是在子线程join 之后打印，此时主线程状态为 WAITING
            System.out.println(parentThread.getName() + " " + parentThread.getState());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
